import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterapp/page/view/MealWidget.dart';
import 'package:flutterapp/utils/screen.dart';

/**
 * ***********************************************
 * 包路径：
 * 类描述：订餐系统
 * 创建人：
 * 创建时间：
 * 修改人：
 * 修改时间：
 * 修改备注：
 * ***********************************************
 */
class OrderMealIndexPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return OrderMealIndexPageState();
  }
}

class OrderMealIndexPageState extends State<OrderMealIndexPage> {
  String chooseLocal = "成都—宏地大厦4楼";

  @override
  Widget build(BuildContext context) {
    setScreenSize(context);
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
            icon: Image.asset(
              'assets/meal/images/ic_btn_back_white.png',
              width: 32,
              height: 32,
            ),
            iconSize: dpWidth(48),
            onPressed: () {
              Navigator.pop(context);
            }),
        centerTitle: true,
        title: Text(
          "订餐",
          style: TextStyle(color: Colors.white, fontSize: spFont(36)),
        ),
        actions: <Widget>[
          FlatButton(
              onPressed: () {
                Navigator.pushNamed(context, "/order_meal_record_page",
                    arguments: "");
              },
              child: Text(
                "订餐记录",
                style: TextStyle(color: Colors.white, fontSize: spFont(28)),
              ))
        ],
      ),
      body: Flex(
        direction: Axis.vertical,
        children: <Widget>[
          Expanded(
              flex: 0,
              child: InkWell(
                child: Container(
                  child: Flex(
                    direction: Axis.horizontal,
                    children: <Widget>[
                      Expanded(
                          flex: 0,
                          child: Padding(
                            padding: EdgeInsets.fromLTRB(dpWidth(28),
                                dpHeight(15), dpWidth(12), dpHeight(15)),
                            child: Text(
                              "选择订餐区域",
                              style: TextStyle(
                                  color: Color.fromARGB(255, 51, 51, 51),
                                  fontSize: spFont(32)),
                            ),
                          )),
                      Expanded(
                        flex: 1,
                        child: Container(
                          padding: EdgeInsets.fromLTRB(0, 0, dpWidth(14), 0),
                          alignment: Alignment.centerRight,
                          child: Row(
                            mainAxisSize: MainAxisSize.min,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Text(
                                chooseLocal,
                                style: TextStyle(
                                    color: Color.fromARGB(255, 102, 102, 102),
                                    fontSize: spFont(28)),
                              ),
                              Image.asset(
                                  "assets/meal/images/ic_right_arrow.png",
                                  width: dpWidth(40),
                                  height: dpWidth(46),
                                  alignment: Alignment.centerRight)
                            ],
                          ),
                        ),
                      )
                    ],
                  ),
                  decoration: BoxDecoration(
                      border: Border(
                          bottom: BorderSide(
                              color: Color.fromARGB(255, 238, 238, 238),
                              width: dpHeight(1),
                              style: BorderStyle.solid))),
                ),
                onTap: () {
                  showMealLocalPopup(context,(String content){
                      setState(() {
                          chooseLocal = content;
                      });
                  });
                },
              )),
          Expanded(
            child: Container(
              child: Column(
                children: <Widget>[
                  MealLabelWidget(),
                  MealItemWidget(),
                  MealItemWidget()
                ],
              ),
            ),
            flex: 1,
          ),
          Expanded(
              flex: 0,
              child: Container(
                height: dpHeight(96),
                padding: EdgeInsets.fromLTRB(
                    dpWidth(10), dpHeight(10), dpWidth(10), dpHeight(10)),
                child: FlatButton(
                  onPressed: () {
                    showDialog(
                        context: context,
                        barrierDismissible: true,
                        builder: (ctx) {
                          return MealSucceedDialog();
                        });
                  },
                  color: Colors.blue,
                  child: ConstrainedBox(
                    constraints: BoxConstraints(minWidth: double.maxFinite),
                    child: Text(
                      "确认订餐",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: spFont(32),
                      ),
                    ),
                  ),
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(dpHeight(48))),
                ),
                decoration: BoxDecoration(
                    border: Border(
                        top: BorderSide(
                            color: Color.fromARGB(255, 238, 238, 238),
                            width: dpHeight(1),
                            style: BorderStyle.solid))),
              ))
        ],
      ),
    );
  }
}
